import { createI18n } from "vue-i18n";
import zhCn from "./zhCn";
import en from "./en";

let lang = "zhCn" as any;

if (navigator.language.startsWith("en")) {
  lang = "en";
} else {
  lang = "zhCn";
}

const i18n = createI18n({
  locale: lang,
  legacy: false, // 修复组件引入i18n时vite脚手架报错的问题
  globalInjection: true, // 全局注册 $t
  messages: {
    zhCn,
    en,
  },
});

export default i18n;
